<!--
 * @Author: HeAo
 * @Date: 2021-10-12 16:58:35
 * @LastEditTime: 2021-10-12 17:07:33
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day04\8-render函数.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <my-com :level="1">
      hello render
    </my-com>
    <my-com :level="2">
      hello render2
    </my-com>
    <my-com :level="3">
      hello render3
    </my-com>
  </div>
  <script>
    let component1 = {
      props: {
        level: {
          type: [Number, String],
          required: true
        }
      },
      data() {
        return {}
      },
      render(creatElement) {
        return creatElement(
          'h' + this.level,  // 生成的html标签
          {
            class: 'box',    // 生成标签上的配置项（属性）
          },
          this.$slots.default// 生成标签的子节点
        )
      }
    }

    let vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      created() { },
      components: {
        myCom: component1
      }
    })
  </script>
</body>

</html>